package com.xe.gae.admin;
	import java.io.IOException;
import java.util.Calendar;
	import java.util.Map;

	import javax.servlet.ServletException;
	import javax.servlet.http.HttpServlet;
	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpServletResponse;

	import com.google.appengine.api.blobstore.BlobInfo;
	import com.google.appengine.api.blobstore.BlobInfoFactory;
	import com.google.appengine.api.blobstore.BlobKey;
	import com.google.appengine.api.blobstore.BlobstoreService;
	import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.xe.gae.control.XEBlobstoreService;

	public class XEUploadServlet extends HttpServlet {
/*	    private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	    private BlobInfoFactory blobinfoFactory= new BlobInfoFactory();

	    public void doPost(HttpServletRequest req, HttpServletResponse res)
	        throws ServletException, IOException {

	        Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
	        BlobKey blobKey = blobs.get("myFile");
	        BlobInfo info = blobinfoFactory.loadBlobInfo(blobKey);
	        
	        if (blobKey == null) {
	            res.sendRedirect("/");
	        } else {
	            //res.sendRedirect("/_xe/admin/serve?blob-key=" + blobKey.getKeyString());
	        	res.sendRedirect("/_xe/admin/browse.jsp?filter=" + info.getFilename());
	        }
	    }
	    */
		
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp)
				throws ServletException, IOException {
			String install=req.getParameter("extract");
			System.out.println(install);
			XEBlobstoreService bss = new XEBlobstoreService();
			
			bss.updateUploadedBlob(req);
			
			resp.sendRedirect("/_xe/admin/browse.jsp?timestamp="+Calendar.getInstance().getTimeInMillis());
		}
	}
	
